Learn R Programming

JMbayes (version 0.8-85)

fitted & residuals: Fitted Values and Residuals for Joint Models

Description

Calculates fitted values for joint models.

Usage

# S3 method for JMbayes
fitted(object, 
    process = c("Longitudinal", "longitudinal", "Event", "event"), 
    type = c("Marginal", "marginal", "Subject", "subject"), nullY = FALSE, …)

# S3 method for JMbayes residuals(object, process = c("Longitudinal", "longitudinal", "Event", "event"), type = c("Marginal", "marginal", "Subject", "subject", "Martingale", "martingale", "nullMartingale", "nullmartingale"), standardized = FALSE, …)

Arguments

object

an object inheriting from class jointModel.

process

for which model (i.e., linear mixed model or survival model) to calculate fitted values or residuals.

type

what type of fitted values or residuals to calculate. See Details.

nullY

logical; if TRUE the association parameters that connect the longitudinal and event time process are set to zero.

standardized

logical; if TRUE standardized residuals are calculated.

additional arguments; currently none is used.

Value

a numeric vector of fitted values or residuals.

Details

For process = "Longitudinal", let \(X\) denote the design matrix for the fixed effects \(\beta\), and \(Z\) the design matrix for the random effects \(b\). Then for type = "Marginal" the fitted values are \(X \hat{\beta},\) whereas for type = "Subject" they are \(X \hat{\beta} + Z \hat{b}\), where \(\hat{\beta}\) and \(\hat{b}\) denote the corresponding posterior means for the fixed and random effects. The corresponding residuals are calculated by subtracting the fitted values from the observed data \(y\). If type = "Subject" and standardized = TRUE, the residuals are divided by the estimated residual standard error.

For process = "Event" function fitted() calculates the cumulative hazard function at each time point a longitudinal measurement has been recorded. If nullY = TRUE, then the cumulative hazard is calculated without the contribution of the longitudinal process. Function residuals() calculates the martingales residuals or the martingale residuals without the contribution of the longitudinal process when type = "nullMartingale".

References

Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.

Examples

Run this code
# NOT RUN {
lmeFit <- lme(log(serBilir) ~ ns(year, 2), data = pbc2,
              random = ~ ns(year, 2) | id)
survFit <- coxph(Surv(years, status2) ~ 1, data = pbc2.id, x = TRUE)
jointFit <- jointModelBayes(lmeFit, survFit, timeVar = "year")

fitted(jointFit, process = "Event")
residuals(jointFit, type = "Subject", standardized = TRUE)
# }

Run the code above in your browser using DataLab